<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>经营日报-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	#calendar{ width: 100%;}
	#modal-delete.opacity{ opacity: 1; z-index: 1052; background: rgba(0,0,0,0.5); }
	.index_title{ font-size: 14px; }
	.cut_btn{ text-align: right; margin: 20px 0; }
	.cut_btn a{ color: #666; border: 1px solid #666; padding: 5px 10px; border-radius: 5px; }
	.cut_btn a:hover{ border: 1px solid #f49900; color: #f49900; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">项目 > [{$project['project_num']}]{$project['project_name']} > 经营日报</div>
	</div>
	<div id="content">
		<div class="classify">
		<ul>
			<li><a href="__APP__/Project/project_situation/id/{$project['id']}">项目概况</a></li>
			<if condition="is_project_function($project['id'],100)">
			<li><a href="__APP__/Project/project_bg/id/{$project['id']}">项目启动表</a></li>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="$project['center_id'] eq 130003">
					<li><a href="__APP__/Project/project_progress/id/{$project['id']}">项目进展</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],100) and ($project['center_id'] eq 130004 or $project['center_id'] eq 130005 or $project['center_id'] eq 130003)">
			<li><a href="__APP__/Project/project_files/id/{$project['id']}">项目过程文件</a></li>
			</if>
			<if condition="is_project_function($project['id'],52)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] neq NULL)">
				<li><a href="__APP__/Project/project_operate/id/{$project['id']}">运营周报</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],137)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] eq '已开业')">
				<li><a href="javascript:;" class="current">经营日报</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] neq NULL)">
					<li><a href="__APP__/Project/project_operate_analysis/id/{$project['id']}">经营数据分析</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="$project['center_id'] eq 130003">
					<li><a href="__APP__/Project/project_communicate/id/{$project['id']}">前期沟通</a></li>
					<li><a href="__APP__/Project/project_negotiation/id/{$project['id']}">商务谈判</a></li>
					<li><a href="__APP__/Project/project_contract/id/{$project['id']}">商务签约</a></li>
				</if>
			</if>
			<if condition="($project['center_id'] eq 130005) and (((get_permission('XM',NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission('XM',NULL,2) and (in_array($project['center_id'],$login_manage_id))) or (get_permission('XM',NULL,1)) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id))">
				<li><a href="__APP__/Project/project_plan/id/{$project['id']}">营销计划</a></li>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] neq NULL)">
					<li><a href="__APP__/Project/project_user/id/{$project['id']}">项目人员</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] neq NULL)">
					<li><a href="__APP__/Index/task_list/pid/{$project['id']}">任务管理</a></li>
				</if>
			</if>
			<if condition="is_project_function($project['id'],100)">
				<if condition="($project['center_id'] eq 130005) and ($project_bg['project_stage'] eq '已开业')">
					<li><a href="__APP__/Project/project_income_month/id/{$project['id']}">月计划执行</a></li>
				</if>
			</if>
			<if condition="($project['center_id'] eq 130005) and (((get_permission('XM',NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission('XM',NULL,2) and strstr($project['center_id'],$login_center_id)) or (get_permission('XM',NULL,1)) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id))">
				<li><a href="__APP__/Project/project_auth/id/{$project['id']}">授权管理</a></li>
			</if>
		</ul>
		</div>
		<div class="cut_btn"><a href="__APP__/Project/project_operat_list/id/{$project['id']}">日历</a></div>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="">日期</td>
					<td width="">门票金额(元)</td>
					<td width="">二次消费金额(元)</td>
					<td width="">总收入(元)</td>
					<td width="">成本(元)</td>
					<if condition="((((get_permission('XM',NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission('XM',NULL,2) and (in_array($project['center_id'],$login_manage_id))) or (get_permission('XM',NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id) or is_project($project['id'],137)) and ($project['status'] eq 1)">
					<td width="">管理</td>
					</if>
				</tr>
				<if condition="$result eq NULL">
				<tr><td class="Text_c" <if condition="((((get_permission('XM',NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission('XM',NULL,2) and (in_array($project['center_id'],$login_manage_id))) or (get_permission('XM',NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id) or is_project($project['id'],137)) and ($project['status'] eq 1)">colspan="6"<else />colspan="5"</if>>暂无相关数据</td></tr>
				</if>
				<foreach name="result" item="vo">
					<tr>
						<td><a class="edit edit1" href='javascript:;'>{$vo['date']}</a></td>
						<td>{$vo['money_m']}</td>
						<td>{$vo['money_e']}</td>
						<td>{$vo['money_all']}</td>
						<td>{$vo['money_c']}</td>
						<if condition="((((get_permission('XM',NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission('XM',NULL,2) and (in_array($project['center_id'],$login_manage_id))) or (get_permission('XM',NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id) or is_project($project['id'],137)) and ($project['status'] eq 1)">
						<td width="80">
							<if condition="$vo['update'] eq 1">
							<a href="javascript:;" mid="{$vo['id']}" data-toggle="tooltip" data-placement="left" title="" class="edit mr5" data-original-title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
							<a href="javascript:;" data-toggle="tooltip" date-src="{$vo['date']}" data-placement="left" title="删除" class="user-delete"><i class="glyphicon glyphicon-trash"></i></a>
							</if>
						</td>
						</if>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!-- 弹框 -->
<div class="modal fade" id="edit_modal">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4>经营日报</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<div class="form-main" style="border:none;margin-bottom:0">
					<form class="add-custome-info2" id="task_user_ap" action="#" method="post">
						<input type="hidden" name="pid" value="{$pid}">
						<div class="form-item clearfix">
							<div class="input-label">日期</div>
							<div class="input-item">
								<span class="txt mr10 ajax_date"></span>
							</div>
						</div>
						<div class="table_cont">

						</div>
						<div class="clearboth mt10">
							<div class="right">
								<span class="error-item zheng mr10">金额必须是数字且可保留2位小数</span><span class="error-item zheng2 mr10">人数必须是整数</span><input type="button" class="btn btn-choise2" value="提交">
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<!--删除弹框-->
<div class="modal fade" id="modal-delete" >
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>确认提示框</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">您确定要删除吗？</div>
			<div class="modal-footer">
				<button type="button" class="btn delete-confirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>

<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//项目切换
	$("[name='project_name']").change(function(){
		var val = $(this).find('option:selected').val();
		location.href="__APP__/Project/project_operat_other/pid/"+val+"";
	})
	$('.btn-default,.fa-times').click(function(){
		$('#modal-delete').fadeOut();
	})
	$('.delete-confirm').click(function(){
		var date = $(this).attr('date'),
			pid = "{$pid}";
		$('#modal-delete,#edit_modal').hide();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"date":date,"action":"delete","pid":pid},
			url:"__APP__/Project/project_operat_list_ajax",
			success:function(data){
				$('#edit_modal,#modal-delete').hide();
				success_pop(data.status,data.msg);
			}
		})
	})
	
	//删除
	$(".user-delete").click(function(){
		var dates = $(this).attr('date-src');
		$('#modal-delete .delete-confirm').attr('date',dates);
		$('#modal-delete').fadeIn().addClass('opacity');
		$('.mask').fadeIn();
	})

	//提交
	$('.btn-choise2').click(function(){
		var tag = true,
			date = $('#edit_modal .txt').text();
		$('#edit_modal .table .tr').each(function(){
			var num = $(this).find("[name='number_copy[]']").val(),
				money = $(this).find("[name='money_copy[]']").val();
			if(num!=''&& money==''){
				$(this).find("[name='money_copy[]']").next('.error-item').show();
				tag = false;
			}
			if(num=='' && money!=''){
				$(this).find("[name='number_copy[]']").next('.error-item').show();
				tag = false;
			}
		})
		$('#edit_modal').find("[name='number_copy[]']").each(function(){
			var val = $(this).val();
			if(!/^\+?[0-9]\d*$/.test(val) && val!=""){
				$('.zheng2').show();
				$(this).addClass('red_border');
				tag = false;
			}
		})
		$('#edit_modal').find("[name='money_copy[]']").each(function(){
			var val = $(this).val();
			if(!/(^[1-9](\d+)?(\.\d{1,2})?$)|(^(0){1}$)|(^\d\.\d{1,2}?$)/.test(val) && val!=""){
				$('.zheng').show();
				$(this).addClass('red_border');
				tag = false;
			}
		})
		if(tag){
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.add-custome-info2').serialize()+"&action=doedit&date="+date,
				url:"__APP__/Project/project_operat_list_ajax",
				success:function(data){
					$('#edit_modal').hide();
					success_pop(data.status);
				}
			})
		}
	})
	//隐藏提示
	$('.required-text').focus(function(){
		$(this).nextAll('.error-item').hide();
	})
	$("body").on("focus","[name='number_copy[]'],[name='money_copy[]']",function(){
		$('.zheng').hide();
		$(this).removeClass('red_border');
	})
	//弹框
	$('.edit').click(function(){
		$('#edit_modal').modal("show");
		var pid = "{$pid}",
			date = $(this).parents('tr').find('.edit1').text();
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"date":date,"action":"edit","pid":pid},
			url:"__APP__/Project/project_operat_list_ajax",
			success:function(data){
				$('#edit_modal .txt').html(date);
				if(data.type==1){
					//编辑
					var html = '';
					html+= "<table class='table table-bordered'>";
					html+= "<tr><th width='80'>类别</th><th width='80'>种类</th><th width='80'>分类</th><th width='120'><span class='asterisk'>*</span>人数</th><th width='120'><span class='asterisk'>*</span>金额（元）</th></tr>";
					for(var i=0;i<data.data.length;i++){
						for(var j=0;j<data.data[i].second.length;j++){
							if(data.data[i].second[j].second_name=='门票'){
								for(var k=0;k<data.data[i].second[j].third.length;k++){
									html+= "<tr class='hb_tr2'>";
									if(k==0){
										html+= "<td rowspan='"+data.data[i].second[j].third.length*2+"'>"+data.data[i].second[j].second_name+"</td>"
									}
									html+= "<td rowspan='2'>"+data.data[i].second[j].third[k].third_name+"</td><td>团队</td><td><input maxlength='10' type='text' name='number_copy[]' value='"+data.data[i].second[j].third[k].number_copy_t+"' class='form-control w100 ml10 mr10 required-text' autocomplete='off'><span class='error-item'>必填项</span><span class='error-item'>必须是正整数</span></td><td><input type='hidden' name='sj_sid_copy[]' class='sj_sid' value='"+data.data[i].second[j].id+"'><input type='hidden' name='sj_tid_copy[]' class='sj_sid' value='"+data.data[i].second[j].third[k].id+"'><input type='hidden' name='sj_pid_copy[]' class='sj_sid' value='团队'><input maxlength='13' type='text' name='money_copy[]' value='"+data.data[i].second[j].third[k].money_copy_t+"' class='form-control w100 ml10 mr10 required-text' autocomplete='off'><span class='error-item'>必填项</span><span class='error-item'>必须是大于0的数字可保留2位小数</span></td></tr>";
									
									html+= "<tr class='hb_tr2'><td>散客</td><td><input maxlength='10' type='text' name='number_copy[]' value='"+data.data[i].second[j].third[k].number_copy_s+"' class='form-control w100 ml10 mr10' autocomplete='off'><span class='error-item'>必填项</span><span class='error-item'>必须是正整数</span></td><td><input type='hidden' name='sj_sid_copy[]' class='sj_sid' value='"+data.data[i].second[j].id+"'><input type='hidden' name='sj_tid_copy[]' class='sj_sid' value='"+data.data[i].second[j].third[k].id+"'><input type='hidden' name='sj_pid_copy[]' class='sj_sid' value='散客'><input maxlength='13' type='text' name='money_copy[]' value='"+data.data[i].second[j].third[k].money_copy_s+"' class='form-control w100 ml10 mr10' autocomplete='off'><span class='error-item'>必填项</span><span class='error-item'>必须是大于0的数字可保留2位小数</span></td></tr>";
								}
							}else{
								for(var k=0;k<data.data[i].second[j].third.length;k++){
									html+= "<tr class='hb_tr2'>";
									if(k==0){
										html+= "<td rowspan='"+data.data[i].second[j].third.length+"'>"+data.data[i].second[j].second_name+"</td>"
									}
									html+= "<td>"+data.data[i].second[j].third[k].third_name+"</td><td></td><td></td><td><input type='hidden' name='sj_sid_copy[]' class='sj_sid' value='"+data.data[i].second[j].id+"'><input type='hidden' name='sj_tid_copy[]' class='sj_sid' value='"+data.data[i].second[j].third[k].id+"'><input type='hidden' name='sj_pid_copy[]' class='sj_sid' value='-10'><input maxlength='13' type='text' name='money_copy[]' value='"+data.data[i].second[j].third[k].money_copy_s+"' class='form-control w100 ml10 mr10' autocomplete='off'><span class='error-item'>必填项</span><span class='error-item'>必须是大于0的数字可保留2位小数</span></td></tr>";
								}
							}
						}
					}
					$('.table_cont').html(html);
					$('#edit_modal .clearboth').show();
					$('#edit_modal .user-delete').attr('date-src',date);
				}else{
					//详情
					var html = '';
					html+= "<table class='table table-bordered'>";
					html+= "<tr><th width='80'><span class='asterisk'>*</span>类别</th><th width='80'><span class='asterisk'>*</span>种类</th><th width='80'><span class='asterisk'>*</span>分类</th><th width='120'><span class='asterisk'>*</span>人数</th><th width='120'><span class='asterisk'>*</span>金额（元）</th></tr>";
					for(var i=0;i<data.data.length;i++){
						for(var j=0;j<data.data[i].second.length;j++){
							if(data.data[i].second[j].second_name=='门票'){
								for(var k=0;k<data.data[i].second[j].third.length;k++){
									html+= "<tr class='hb_tr2'>";
									if(k==0){
										html+= "<td rowspan='"+data.data[i].second[j].third.length*2+"'>"+data.data[i].second[j].second_name+"</td>"
									}
									html+= "<td rowspan='2'>"+data.data[i].second[j].third[k].third_name+"</td><td>团队</td><td>"+data.data[i].second[j].third[k].number_copy_t+"</td><td>"+data.data[i].second[j].third[k].money_copy_t+"</td></tr>";
									
									html+= "<tr class='hb_tr2'><td>散客</td><td>"+data.data[i].second[j].third[k].number_copy_s+"</td><td>"+data.data[i].second[j].third[k].money_copy_s+"</td></tr>";
								}
								html+= "<tr class='hb_tr2'><td>门票合计</td><td colspan='2'></td><td>"+data.data[i].second[j].n_sum_all+"</td><td>"+data.data[i].second[j].m_sum_all+"</td></tr>";
							}else if(data.data[i].second[j].second_name=='二次消费'){
								for(var k=0;k<data.data[i].second[j].third.length;k++){
									html+= "<tr class='hb_tr2'>";
									if(k==0){
										html+= "<td rowspan='"+data.data[i].second[j].third.length+"'>"+data.data[i].second[j].second_name+"</td>"
									}
									html+= "<td>"+data.data[i].second[j].third[k].third_name+"</td><td></td><td></td><td>"+data.data[i].second[j].third[k].money_copy_s+"</td></tr>";
								}
								html+= "<tr class='hb_tr2'><td>二次消费合计</td><td colspan='3'></td><td>"+data.data[i].second[j].m_sum_all+"</td></tr>";
								html+= "<tr class='hb_tr2'><td>收入总计</td><td colspan='2'></td><td>"+data.data[i].zn_sum_all+"</td><td>"+data.data[i].zm_sum_all+"</td></tr>";
							}else if(data.data[i].second[j].second_name=='成本'){
								for(var k=0;k<data.data[i].second[j].third.length;k++){
									html+= "<tr class='hb_tr2'>";
									if(k==0){
										html+= "<td rowspan='"+data.data[i].second[j].third.length+"'>"+data.data[i].second[j].second_name+"</td>"
									}
									html+= "<td>"+data.data[i].second[j].third[k].third_name+"</td><td></td><td></td><td>"+data.data[i].second[j].third[k].money_copy_s+"</td></tr>";
								}
								html+= "<tr class='hb_tr2'><td>成本合计</td><td colspan='3'></td><td>"+data.data[i].second[j].m_sum_all+"</td></tr>";
							}
						}
					}
					$('.table_cont').html(html);
					$('#edit_modal .clearboth').hide();
				}
			}
		});
	})

});
</script>
</body>
</html>